#define _CRT_SECURE_NO_WARNINGS 1

#include<assert.h>
#include <string.h>
#include <stdio.h>
int my_strcmp(const char* str1, const char* str2)
{
    int ret = 0;
    assert(str1 && str2);
    while (*str1 == *str2)
    {
        if (*str1 == '\0')
            return 0;
        str1++;
        str2++;
    }
    return *str1 - *str2;
}

char* my_strstr(const char* str1, const char* str2)
{
    char* cp = (char*)str1;
    char* s1, * s2;
    if (!*str2)
        return((char*)str1);
    while (*cp)
    {
        s1 = cp;
        s2 = (char*)str2;
        while (*s1 && *s2 && !(*s1 - *s2))
            s1++, s2++;
        if (!*s2)
            return(cp);
        cp++;
    }
    return(NULL);
}
int main()
{
    const char* str1 = "hello world";
    const char* str2 = "world";

    char* result = my_strstr(str1, str2);

    if (result != NULL) {
        printf("'%s' found in '%s' at position: %ld\n", str2, str1, result - str1);
    }
    else {
        printf("'%s' not found in '%s'\n", str2, str1);
    }

    //char* s1 = "asdfghjk";
    //char* s2 = "zgxyvxhiiincksic";
    //printf("%d", my_strcmp(s1, s2));
    return 0;
}
